#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "gamewindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    initUI();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::initUI()
{
    setWindowIcon(QIcon(":/Image/m_icon.png"));

    //initMenu();

    initConnection();
}

//void MainWindow::initMenu()
//{

//}

void MainWindow::initConnection()
{
    connect(ui->pushButton_classic,&QPushButton::clicked,[=]()
    {

        this->classic.show();
        classic.on_classic_press();
        this->setVisible(0);


    });//
    //connect(ui->pushButton_classic,&QPushButton::clicked,&classic,&classic.on_classic_press);

    connect(ui->pushButton_simple,&QPushButton::clicked,[=]()
    {
        this->simple.show();
        simple.on_simple_press();
        this->setVisible(0);

    });
    //connect(ui->pushButton_simple,&QPushButton::clicked,&simple,&simple.on_simple_press);

    connect(ui->pushButton_medium,&QPushButton::clicked,[=]()
    {
        this->medium.show();
        medium.on_medium_press();
        this->setVisible(0);


    });
    //connect(ui->pushButton_medium,&QPushButton::clicked,&medium,&classic.on_medium_press);


    connect(ui->pushButton_experts,&QPushButton::clicked,[=]()
    {
        this->experts.show();
        experts.on_experts_press();
        this->setVisible(0);

    });
    //connect(ui->pushButton_experts,&QPushButton::clicked,&experts,&classic.on_experts_press);

    connect(ui->pushButton_theCustom,&QPushButton::clicked,[=]()
    {
        this->theCustom.show();
        theCustom.on_theCustom_press();
//        this->hide();
        this->setVisible(0);
    });
    //connect(ui->pushButton_theCustom,&QPushButton::clicked,&theCustom,&theCustom.on_theCustom_press);


    connect(&classic,&GameWindow::return_mainwindow,this,[=]()
    {
       this->setVisible(1);
    });

    connect(&simple,&GameWindow::return_mainwindow,this,[=]()
    {
       this->setVisible(1);
    });

    connect(&medium,&GameWindow::return_mainwindow,this,[=]()
    {
       this->setVisible(1);
    });

    connect(&experts,&GameWindow::return_mainwindow,this,[=]()
    {
       this->setVisible(1);
    });

    connect(&theCustom,&GameWindow::return_mainwindow,this,[=]()
    {
       this->setVisible(1);
    });
}



